package com.sc.nft.admin.controller;


import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.SpecialEventManagementEditDTO;
import com.sc.nft.entity.dto.SpecialEventManagementPageDTO;
import com.sc.nft.entity.dto.SpecialEventManagementSaveDTO;
import com.sc.nft.entity.vo.SpecialEventManagementPageVO;
import com.sc.nft.service.SpecialEventManagementService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 专场管理(SpecialEventManagement)表控制层
 *
 * @author 王伟成
 * @since 2023-10-10 16:00:48
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/specialEventManagement")
@Api(tags = "专场管理")
@Valid
public class SpecialEventManagementController {
    /**
     * 服务对象
     */
    private final SpecialEventManagementService specialEventManagementService;


    @PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增", notes = "新增", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result save(@RequestBody SpecialEventManagementSaveDTO specialEventManagementSaveDTO) {
        specialEventManagementService.save(specialEventManagementSaveDTO);
        return Result.success();
    }

    @PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑", notes = "编辑", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result edit(@RequestBody SpecialEventManagementEditDTO specialEventManagementEditDTO) {
        specialEventManagementService.edit(specialEventManagementEditDTO);
        return Result.success();
    }

    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "分页", notes = "分页", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<SpecialEventManagementPageVO> page(@RequestBody SpecialEventManagementPageDTO specialEventManagementPageDTO) {
        return PageResult.success(specialEventManagementService.page(specialEventManagementPageDTO));
    }

    @PostMapping(value = "/getById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取单条", notes = "获取单条", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<SpecialEventManagementPageVO> getById(@RequestBody IdRequest idRequest) {
        return Result.success(specialEventManagementService.getById(idRequest.getId()));
    }

    @PostMapping(value = "/removeById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除单条", notes = "删除单条", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result removeById(@RequestBody IdRequest idRequest) {
        specialEventManagementService.removeById(idRequest.getId());
        return Result.success();
    }

    @PostMapping(value = "/unmount", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "上下架", notes = "上下架", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result unmount(@RequestBody IdRequest idRequest) {
        specialEventManagementService.unmount(idRequest.getId());
        return Result.success();
    }
}
